The first thing we need to do is import the turtle library:
import turtle
We then need to create a turtle object, which we conventionally call “t”:
t = turtle.Pen()
If you want, you can change the shape to an “arrow”, “turtle”, “circle”, “square”, “triangle”, or “classic”. The default shape is “classic”.
t.shape("triangle")
If we run a program with these two commands we might find that the window closes immediately, so let’s prevent that by adding the command:
turtle.exitonclick()
In [1]:
import turtle
t = turtle.Pen()
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
turtle.exitonclick()
In [ ]: